package servlet;

import hbase.UserLogFromHBase;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;


@WebServlet("/Query")
public class HbaseQuery extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String name  = req.getParameter("name");

        UserLogFromHBase userLogFromHBase = new UserLogFromHBase();
        String [] stringObject = new String[2];
        stringObject[0] = "cf1";
        stringObject[1] = "cf2";
        List<String> stringList = userLogFromHBase.getUserLogList("student",stringObject);

        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw =  resp.getWriter();
        pw.write("<p>"+stringList);

        req.setAttribute("objResult",stringList);
        req.getRequestDispatcher("/queryResult.jsp").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}